package ui;

import impl.Core;
import impl.Employee;
import impl.Manager;
import impl.Relative;
import java.io.IOException;
import java.lang.String;
import java.util.List;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import utils.Arquivos;

public class mainUI extends javax.swing.JFrame {

    Core core;
    Manager manager;
    boolean next = false;

    public mainUI() throws IOException {
        core = new Core();
        manager = new Manager();
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroupBusca = new javax.swing.ButtonGroup();
        jFrameEditFunc = new javax.swing.JFrame();
        jPanelEditFunc = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jTextFieldEditNomeFunc = new javax.swing.JTextField();
        jTextFieldEditAgeFunc = new javax.swing.JTextField();
        jTextFieldEditSalFunc = new javax.swing.JTextField();
        jButtonEditFunc = new javax.swing.JButton();
        jButtonEditCancelFunc = new javax.swing.JButton();
        jFrameEditDept = new javax.swing.JFrame();
        jPanelEditDept = new javax.swing.JPanel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jTextFieldEditNomeDept = new javax.swing.JTextField();
        jTextFieldEditAgeDept = new javax.swing.JTextField();
        jTextFieldEditFuncDept = new javax.swing.JTextField();
        jButtonEditDept = new javax.swing.JButton();
        jButtonEditCancelDept = new javax.swing.JButton();
        buttonGroupDelete = new javax.swing.ButtonGroup();
        buttonGroupEdit = new javax.swing.ButtonGroup();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanelCadastra = new javax.swing.JPanel();
        jPanelCadFunc = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jTextFieldCadNomeFunc = new javax.swing.JTextField();
        jTextFieldCadAgeFunc = new javax.swing.JTextField();
        jTextFieldCadSalFunc = new javax.swing.JTextField();
        jButtonCadastraFunc = new javax.swing.JButton();
        jButtonCancelaFunc = new javax.swing.JButton();
        jPanelCadDep = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jTextFieldCadNomeDept = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jTextFieldCadAgeDept = new javax.swing.JTextField();
        jButtonCadastraDept = new javax.swing.JButton();
        jButtonCancelaDept = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jTextFieldCadDeptFunc = new javax.swing.JTextField();
        jPanel8 = new javax.swing.JPanel();
        jRadioButtonDelFunc = new javax.swing.JRadioButton();
        jRadioButtonDelDept = new javax.swing.JRadioButton();
        jTextFieldDelCode = new javax.swing.JTextField();
        jLabel23 = new javax.swing.JLabel();
        jButtonDelete = new javax.swing.JButton();
        jPanel9 = new javax.swing.JPanel();
        jRadioButtonEditFunc = new javax.swing.JRadioButton();
        jRadioButtonEditDept = new javax.swing.JRadioButton();
        jLabel24 = new javax.swing.JLabel();
        jTextFieldEditCode = new javax.swing.JTextField();
        jButtonEdit = new javax.swing.JButton();
        jButtonPrint = new javax.swing.JButton();
        jButtonReset = new javax.swing.JButton();
        jPanelBusca = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jRadioButtonBuscaFunc = new javax.swing.JRadioButton();
        jRadioButtonBuscaDept = new javax.swing.JRadioButton();
        jRadioButtonListDept = new javax.swing.JRadioButton();
        jRadioButtonListFunc = new javax.swing.JRadioButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jTextFieldBuscaNomeFunc = new javax.swing.JTextField();
        jTextFieldBuscaMinAgeFunc = new javax.swing.JTextField();
        jTextFieldBuscaMaxAgeFunc = new javax.swing.JTextField();
        jTextFieldBuscaMinSalFunc = new javax.swing.JTextField();
        jTextFieldBuscaMaxSalFunc = new javax.swing.JTextField();
        jTextFieldBuscaMinDeptsFunc = new javax.swing.JTextField();
        jTextFieldBuscaMaxDeptsFunc = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        jTextFieldBuscaMaxAgeDept = new javax.swing.JTextField();
        jTextFieldBuscaMinAgeDept = new javax.swing.JTextField();
        jTextFieldBuscaNomeDept = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jScrollPaneResultadoBusca = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jPanel5 = new javax.swing.JPanel();
        jButtonBuscaCancelar = new javax.swing.JButton();
        jButtonBuscaBuscar = new javax.swing.JButton();

        jFrameEditFunc.setTitle("Editar Funcionário");
        jFrameEditFunc.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jFrameEditFunc.setLocationByPlatform(true);
        jFrameEditFunc.setMinimumSize(new java.awt.Dimension(500, 200));

        jLabel8.setText("Nome:");

        jLabel15.setText("Idade:");

        jLabel16.setText("Salário:");

        jButtonEditFunc.setText("Confirmar");
        jButtonEditFunc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonEditFuncActionPerformed(evt);
            }
        });

        jButtonEditCancelFunc.setText("Cancelar");
        jButtonEditCancelFunc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonEditCancelFuncActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelEditFuncLayout = new javax.swing.GroupLayout(jPanelEditFunc);
        jPanelEditFunc.setLayout(jPanelEditFuncLayout);
        jPanelEditFuncLayout.setHorizontalGroup(
            jPanelEditFuncLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelEditFuncLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelEditFuncLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelEditFuncLayout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addGap(10, 10, 10)
                        .addComponent(jTextFieldEditNomeFunc, javax.swing.GroupLayout.DEFAULT_SIZE, 427, Short.MAX_VALUE))
                    .addGroup(jPanelEditFuncLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanelEditFuncLayout.createSequentialGroup()
                            .addComponent(jLabel16)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jTextFieldEditSalFunc))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanelEditFuncLayout.createSequentialGroup()
                            .addComponent(jLabel15)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jTextFieldEditAgeFunc, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelEditFuncLayout.createSequentialGroup()
                        .addComponent(jButtonEditCancelFunc)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButtonEditFunc)))
                .addContainerGap())
        );

        jPanelEditFuncLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButtonEditCancelFunc, jButtonEditFunc});

        jPanelEditFuncLayout.setVerticalGroup(
            jPanelEditFuncLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelEditFuncLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelEditFuncLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jTextFieldEditNomeFunc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanelEditFuncLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(jTextFieldEditAgeFunc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanelEditFuncLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(jTextFieldEditSalFunc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelEditFuncLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonEditFunc)
                    .addComponent(jButtonEditCancelFunc, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanelEditFuncLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jButtonEditCancelFunc, jButtonEditFunc});

        javax.swing.GroupLayout jFrameEditFuncLayout = new javax.swing.GroupLayout(jFrameEditFunc.getContentPane());
        jFrameEditFunc.getContentPane().setLayout(jFrameEditFuncLayout);
        jFrameEditFuncLayout.setHorizontalGroup(
            jFrameEditFuncLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelEditFunc, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jFrameEditFuncLayout.setVerticalGroup(
            jFrameEditFuncLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelEditFunc, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        jFrameEditFunc.getAccessibleContext().setAccessibleParent(this);

        jFrameEditDept.setTitle("Editar Dependente");
        jFrameEditDept.setLocationByPlatform(true);
        jFrameEditDept.setMinimumSize(new java.awt.Dimension(500, 200));

        jLabel17.setText("Nome:");

        jLabel18.setText("Idade:");

        jLabel22.setText("Funcionário:");

        jButtonEditDept.setText("Confirmar");
        jButtonEditDept.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonEditDeptActionPerformed(evt);
            }
        });

        jButtonEditCancelDept.setText("Cancelar");
        jButtonEditCancelDept.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonEditCancelDeptActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelEditDeptLayout = new javax.swing.GroupLayout(jPanelEditDept);
        jPanelEditDept.setLayout(jPanelEditDeptLayout);
        jPanelEditDeptLayout.setHorizontalGroup(
            jPanelEditDeptLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelEditDeptLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelEditDeptLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelEditDeptLayout.createSequentialGroup()
                        .addComponent(jLabel17)
                        .addGap(10, 10, 10)
                        .addComponent(jTextFieldEditNomeDept, javax.swing.GroupLayout.DEFAULT_SIZE, 427, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelEditDeptLayout.createSequentialGroup()
                        .addComponent(jButtonEditCancelDept)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButtonEditDept))
                    .addGroup(jPanelEditDeptLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanelEditDeptLayout.createSequentialGroup()
                            .addComponent(jLabel18)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jTextFieldEditAgeDept))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanelEditDeptLayout.createSequentialGroup()
                            .addComponent(jLabel22)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jTextFieldEditFuncDept, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
        );
        jPanelEditDeptLayout.setVerticalGroup(
            jPanelEditDeptLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelEditDeptLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelEditDeptLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(jTextFieldEditNomeDept, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanelEditDeptLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel18)
                    .addComponent(jTextFieldEditAgeDept, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanelEditDeptLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldEditFuncDept, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel22))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelEditDeptLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonEditDept)
                    .addComponent(jButtonEditCancelDept, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanelEditDeptLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jButtonEditCancelDept, jButtonEditDept});

        javax.swing.GroupLayout jFrameEditDeptLayout = new javax.swing.GroupLayout(jFrameEditDept.getContentPane());
        jFrameEditDept.getContentPane().setLayout(jFrameEditDeptLayout);
        jFrameEditDeptLayout.setHorizontalGroup(
            jFrameEditDeptLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 488, Short.MAX_VALUE)
            .addComponent(jPanelEditDept, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jFrameEditDeptLayout.setVerticalGroup(
            jFrameEditDeptLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 157, Short.MAX_VALUE)
            .addComponent(jPanelEditDept, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        jFrameEditDept.getAccessibleContext().setAccessibleParent(this);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Trabalho ED2");
        setLocationByPlatform(true);
        setMinimumSize(new java.awt.Dimension(300, 400));
        setResizable(false);

        jTabbedPane1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jTabbedPane1FocusGained(evt);
            }
        });

        jPanelCadFunc.setBorder(javax.swing.BorderFactory.createTitledBorder("Funcionário"));

        jLabel1.setText("Nome:");

        jLabel5.setText("Idade:");

        jLabel6.setText("Salário:");

        jButtonCadastraFunc.setText("Cadastra");
        jButtonCadastraFunc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCadastraFuncActionPerformed(evt);
            }
        });

        jButtonCancelaFunc.setText("Cancela");
        jButtonCancelaFunc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCancelaFuncActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelCadFuncLayout = new javax.swing.GroupLayout(jPanelCadFunc);
        jPanelCadFunc.setLayout(jPanelCadFuncLayout);
        jPanelCadFuncLayout.setHorizontalGroup(
            jPanelCadFuncLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelCadFuncLayout.createSequentialGroup()
                .addGroup(jPanelCadFuncLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelCadFuncLayout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTextFieldCadAgeFunc, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldCadSalFunc, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanelCadFuncLayout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTextFieldCadNomeFunc, javax.swing.GroupLayout.DEFAULT_SIZE, 444, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelCadFuncLayout.createSequentialGroup()
                        .addComponent(jButtonCadastraFunc, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonCancelaFunc, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        jPanelCadFuncLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jTextFieldCadAgeFunc, jTextFieldCadSalFunc});

        jPanelCadFuncLayout.setVerticalGroup(
            jPanelCadFuncLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelCadFuncLayout.createSequentialGroup()
                .addGroup(jPanelCadFuncLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelCadFuncLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel1)
                        .addComponent(jTextFieldCadNomeFunc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanelCadFuncLayout.createSequentialGroup()
                        .addGap(31, 31, 31)
                        .addGroup(jPanelCadFuncLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jTextFieldCadAgeFunc, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6)
                            .addComponent(jTextFieldCadSalFunc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
                .addGroup(jPanelCadFuncLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonCadastraFunc)
                    .addComponent(jButtonCancelaFunc))
                .addContainerGap())
        );

        jPanelCadDep.setBorder(javax.swing.BorderFactory.createTitledBorder("Dependente"));

        jLabel2.setText("Nome:");

        jLabel7.setText("Idade:");

        jButtonCadastraDept.setText("Cadastra");
        jButtonCadastraDept.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCadastraDeptActionPerformed(evt);
            }
        });

        jButtonCancelaDept.setText("Cancela");
        jButtonCancelaDept.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCancelaDeptActionPerformed(evt);
            }
        });

        jLabel4.setText("Funcionário:");

        javax.swing.GroupLayout jPanelCadDepLayout = new javax.swing.GroupLayout(jPanelCadDep);
        jPanelCadDep.setLayout(jPanelCadDepLayout);
        jPanelCadDepLayout.setHorizontalGroup(
            jPanelCadDepLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelCadDepLayout.createSequentialGroup()
                .addGroup(jPanelCadDepLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelCadDepLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTextFieldCadNomeDept, javax.swing.GroupLayout.DEFAULT_SIZE, 445, Short.MAX_VALUE))
                    .addGroup(jPanelCadDepLayout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanelCadDepLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelCadDepLayout.createSequentialGroup()
                                .addGap(181, 181, 181)
                                .addComponent(jButtonCadastraDept, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButtonCancelaDept, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE))
                            .addGroup(jPanelCadDepLayout.createSequentialGroup()
                                .addComponent(jTextFieldCadAgeDept, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextFieldCadDeptFunc, javax.swing.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE)))))
                .addContainerGap())
        );
        jPanelCadDepLayout.setVerticalGroup(
            jPanelCadDepLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelCadDepLayout.createSequentialGroup()
                .addGroup(jPanelCadDepLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTextFieldCadNomeDept, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelCadDepLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jTextFieldCadAgeDept, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(jTextFieldCadDeptFunc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
                .addGroup(jPanelCadDepLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonCadastraDept)
                    .addComponent(jButtonCancelaDept))
                .addContainerGap())
        );

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Exclusão"));

        buttonGroupDelete.add(jRadioButtonDelFunc);
        jRadioButtonDelFunc.setSelected(true);
        jRadioButtonDelFunc.setText("Funcionário");

        buttonGroupDelete.add(jRadioButtonDelDept);
        jRadioButtonDelDept.setText("Dependente");

        jLabel23.setText("Código:");

        jButtonDelete.setText("Excluir");
        jButtonDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDeleteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addComponent(jLabel23)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldDelCode))
                    .addComponent(jRadioButtonDelFunc))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jRadioButtonDelDept, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonDelete, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE))
                .addGap(14, 14, 14))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRadioButtonDelFunc)
                    .addComponent(jRadioButtonDelDept))
                .addGap(18, 18, 18)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldDelCode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonDelete)
                    .addComponent(jLabel23))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder("Edição"));

        buttonGroupEdit.add(jRadioButtonEditFunc);
        jRadioButtonEditFunc.setSelected(true);
        jRadioButtonEditFunc.setText("Funcionário");

        buttonGroupEdit.add(jRadioButtonEditDept);
        jRadioButtonEditDept.setText("Dependente");

        jLabel24.setText("Código:");

        jButtonEdit.setText("Editar");
        jButtonEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonEditActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addComponent(jLabel24)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldEditCode, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jRadioButtonEditFunc))
                .addGap(18, 18, 18)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jRadioButtonEditDept)
                    .addComponent(jButtonEdit, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRadioButtonEditFunc)
                    .addComponent(jRadioButtonEditDept))
                .addGap(18, 18, 18)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldEditCode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonEdit)
                    .addComponent(jLabel24))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButtonPrint.setText("Print");
        jButtonPrint.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPrintActionPerformed(evt);
            }
        });

        jButtonReset.setText("Reset");
        jButtonReset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonResetActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelCadastraLayout = new javax.swing.GroupLayout(jPanelCadastra);
        jPanelCadastra.setLayout(jPanelCadastraLayout);
        jPanelCadastraLayout.setHorizontalGroup(
            jPanelCadastraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelCadFunc, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanelCadDep, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(jPanelCadastraLayout.createSequentialGroup()
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelCadastraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelCadastraLayout.createSequentialGroup()
                        .addComponent(jButtonPrint, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButtonReset, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );
        jPanelCadastraLayout.setVerticalGroup(
            jPanelCadastraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelCadastraLayout.createSequentialGroup()
                .addComponent(jPanelCadFunc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanelCadDep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanelCadastraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelCadastraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonReset)
                    .addComponent(jButtonPrint))
                .addContainerGap())
        );

        jPanelCadastraLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jPanelCadDep, jPanelCadFunc});

        jTabbedPane1.addTab("Cadastro Funcionário", jPanelCadastra);

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        buttonGroupBusca.add(jRadioButtonBuscaFunc);
        jRadioButtonBuscaFunc.setSelected(true);
        jRadioButtonBuscaFunc.setText("Funcionário");

        buttonGroupBusca.add(jRadioButtonBuscaDept);
        jRadioButtonBuscaDept.setText("Dependente");

        buttonGroupBusca.add(jRadioButtonListDept);
        jRadioButtonListDept.setText("Listar Dependentes");

        buttonGroupBusca.add(jRadioButtonListFunc);
        jRadioButtonListFunc.setText("Listar Funcionários");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jRadioButtonBuscaFunc)
                .addGap(10, 10, 10)
                .addComponent(jRadioButtonBuscaDept)
                .addGap(10, 10, 10)
                .addComponent(jRadioButtonListFunc)
                .addGap(10, 10, 10)
                .addComponent(jRadioButtonListDept)
                .addContainerGap(74, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                .addComponent(jRadioButtonBuscaFunc)
                .addComponent(jRadioButtonBuscaDept)
                .addComponent(jRadioButtonListDept)
                .addComponent(jRadioButtonListFunc))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Informações de Funcionário"));

        jLabel3.setText("Nome:");

        jLabel9.setText("Idade Mínima:");

        jLabel10.setText("Idade Máxima:");

        jLabel11.setText("Salário Mínimo:");

        jLabel12.setText("Salário Máximo:");

        jLabel13.setText("Nº Deps. Máximo:");

        jLabel14.setText("Nº Deps. Mínimo:");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9)
                            .addComponent(jLabel11)
                            .addComponent(jLabel14))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTextFieldBuscaMinSalFunc, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jTextFieldBuscaMinDeptsFunc, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jTextFieldBuscaMinAgeFunc, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel10)
                            .addComponent(jLabel12)
                            .addComponent(jLabel13))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTextFieldBuscaMaxAgeFunc, javax.swing.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE)
                            .addComponent(jTextFieldBuscaMaxSalFunc)
                            .addComponent(jTextFieldBuscaMaxDeptsFunc)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldBuscaNomeFunc, javax.swing.GroupLayout.DEFAULT_SIZE, 451, Short.MAX_VALUE)))
                .addContainerGap())
        );

        jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jTextFieldBuscaMaxAgeFunc, jTextFieldBuscaMaxDeptsFunc, jTextFieldBuscaMaxSalFunc, jTextFieldBuscaMinAgeFunc, jTextFieldBuscaMinDeptsFunc, jTextFieldBuscaMinSalFunc});

        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTextFieldBuscaNomeFunc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(jTextFieldBuscaMinAgeFunc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11)
                            .addComponent(jTextFieldBuscaMinSalFunc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel14)
                            .addComponent(jTextFieldBuscaMinDeptsFunc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel10)
                            .addComponent(jTextFieldBuscaMaxAgeFunc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldBuscaMaxSalFunc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel12))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldBuscaMaxDeptsFunc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel13))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Informações de Dependente"));

        jLabel19.setText("Nome:");

        jLabel20.setText("Idade Mínima:");

        jLabel21.setText("Idade Máxima:");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel20)
                        .addGap(19, 19, 19)
                        .addComponent(jTextFieldBuscaMinAgeDept, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel21)
                        .addGap(18, 18, 18)
                        .addComponent(jTextFieldBuscaMaxAgeDept, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel19)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldBuscaNomeDept, javax.swing.GroupLayout.DEFAULT_SIZE, 451, Short.MAX_VALUE)))
                .addContainerGap())
        );

        jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jTextFieldBuscaMaxAgeDept, jTextFieldBuscaMinAgeDept});

        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(jTextFieldBuscaNomeDept, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20)
                    .addComponent(jTextFieldBuscaMinAgeDept, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel21)
                    .addComponent(jTextFieldBuscaMaxAgeDept, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Resultado"));

        jScrollPaneResultadoBusca.setViewportView(jList1);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPaneResultadoBusca, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 496, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jScrollPaneResultadoBusca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButtonBuscaCancelar.setText("Cancelar");
        jButtonBuscaCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscaCancelarActionPerformed(evt);
            }
        });

        jButtonBuscaBuscar.setText("Buscar");
        jButtonBuscaBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscaBuscarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap(320, Short.MAX_VALUE)
                .addComponent(jButtonBuscaCancelar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButtonBuscaBuscar)
                .addGap(8, 8, 8))
        );

        jPanel5Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButtonBuscaBuscar, jButtonBuscaCancelar});

        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonBuscaCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonBuscaBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanelBuscaLayout = new javax.swing.GroupLayout(jPanelBusca);
        jPanelBusca.setLayout(jPanelBuscaLayout);
        jPanelBuscaLayout.setHorizontalGroup(
            jPanelBuscaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelBuscaLayout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanelBuscaLayout.setVerticalGroup(
            jPanelBuscaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelBuscaLayout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Buscar", jPanelBusca);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 513, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jTabbedPane1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTabbedPane1FocusGained
}//GEN-LAST:event_jTabbedPane1FocusGained

private void jButtonCadastraFuncActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCadastraFuncActionPerformed
    //cadastra um novo funcionário
    String name = jTextFieldCadNomeFunc.getText();
    String age = jTextFieldCadAgeFunc.getText();
    String salary = jTextFieldCadSalFunc.getText();
    if (manager.isValidField(Manager.NAME_FIELD, name) && manager.isValidField(Manager.AGE_FIELD, age) && manager.isValidField(Manager.SALARY_FIELD, salary)) {
        if (core.addEmployee(name, Integer.valueOf(age), Double.valueOf(salary))) {
            JOptionPane.showMessageDialog(rootPane, "Funcionário inserido com sucesso!");
        } else {
            JOptionPane.showMessageDialog(rootPane, "Erro ao inserir funcionário");
        }
    }
    core.print();
}//GEN-LAST:event_jButtonCadastraFuncActionPerformed

private void jButtonCadastraDeptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCadastraDeptActionPerformed
    String name = jTextFieldCadNomeDept.getText();
    String age = jTextFieldCadAgeDept.getText();
    String employee = jTextFieldCadDeptFunc.getText();
    if (manager.isValidField(Manager.NAME_FIELD, name) && manager.isValidField(Manager.AGE_FIELD, age) && manager.isValidField(Manager.NAME_FIELD, employee)) {
        if (core.addRelative(name, Integer.valueOf(age), employee)) {
            JOptionPane.showMessageDialog(rootPane, "Dependente inserido com sucesso!");
        } else {
            JOptionPane.showMessageDialog(rootPane, "Erro ao inserir dependente");
        }
    }
    core.print();
}//GEN-LAST:event_jButtonCadastraDeptActionPerformed

private void jButtonCancelaFuncActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelaFuncActionPerformed
    jTextFieldCadNomeFunc.setText("");
    jTextFieldCadAgeFunc.setText("");
    jTextFieldCadSalFunc.setText("");
}//GEN-LAST:event_jButtonCancelaFuncActionPerformed

private void jButtonCancelaDeptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelaDeptActionPerformed
    jTextFieldCadNomeDept.setText("");
    jTextFieldCadAgeDept.setText("");
    jTextFieldCadDeptFunc.setText("");
}//GEN-LAST:event_jButtonCancelaDeptActionPerformed

private void jButtonBuscaCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscaCancelarActionPerformed
    jTextFieldBuscaNomeFunc.setText("");
    jTextFieldBuscaNomeDept.setText("");
    jTextFieldBuscaMinSalFunc.setText("");
    jTextFieldBuscaMaxSalFunc.setText("");
    jTextFieldBuscaMaxAgeDept.setText("");
    jTextFieldBuscaMinAgeDept.setText("");
    jTextFieldBuscaMaxAgeFunc.setText("");
    jTextFieldBuscaMinAgeFunc.setText("");
    jTextFieldBuscaMaxDeptsFunc.setText("");
    jTextFieldBuscaMinDeptsFunc.setText("");
    jList1.setListData(new Vector<String>());
}//GEN-LAST:event_jButtonBuscaCancelarActionPerformed

private void jButtonBuscaBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscaBuscarActionPerformed
    try {
        if (jRadioButtonBuscaFunc.isSelected()) {
            //busca funcionário pelo nome
            List<Employee> employees = null;
            String name = null;
            String minAge = null;
            String maxAge = null;
            String minSalary = null;
            String maxSalary = null;
            String minDept = null;
            String maxDept = null;

            if (manager.isNotEmpty(jTextFieldBuscaNomeFunc.getText())) {
                name = jTextFieldBuscaNomeFunc.getText();
                if (manager.isValidField(Manager.NAME_FIELD, name)) {
                    try {
                        employees = core.searchEmployeeByName(employees, name);
                        Vector<String> employeNames = new Vector<String>();
                        if (!employees.isEmpty()) {
                            for (Employee e : employees) {
                                employeNames.add(e.toString());
                            }
                        } else {
                            employeNames.add("[Nenhum resultado encontrado]");
                        }
                        jList1.setListData(employeNames);
                    } catch (Exception e) {
                        JOptionPane.showMessageDialog(this, "Erro ao realizar busca!");
                    }
                } else {
                    JOptionPane.showMessageDialog(this, "Nome inválido!");
                }
            }
            if (manager.isNotEmpty(jTextFieldBuscaMinAgeFunc.getText(), jTextFieldBuscaMaxAgeFunc.getText())) {
                //busca funcionário pela idade
                minAge = jTextFieldBuscaMinAgeFunc.getText();
                maxAge = jTextFieldBuscaMaxAgeFunc.getText();

                if (manager.isValidField(Manager.AGE_FIELD, minAge) || manager.isValidField(Manager.AGE_FIELD, maxAge)) {
                    try {
                        employees = core.searchEmployeeByAge(employees, Integer.valueOf(minAge), Integer.valueOf(maxAge));
                        Vector<String> employeNames = new Vector<String>();
                        if (!employees.isEmpty()) {
                            for (Employee e : employees) {
                                employeNames.add(e.toString());
                            }
                        } else {
                            employeNames.add("[Nenhum resultado encontrado]");
                        }
                        jList1.setListData(employeNames);
                    } catch (Exception e) {
                        JOptionPane.showMessageDialog(this, "Erro ao realizar busca!");
                    }
                } else {
                    JOptionPane.showMessageDialog(this, "Idade inválida!");
                }
            }
            if (manager.isNotEmpty(jTextFieldBuscaMinSalFunc.getText(), jTextFieldBuscaMaxSalFunc.getText())) {
                //busca funcionário pelo salário
                minSalary = jTextFieldBuscaMinSalFunc.getText();
                maxSalary = jTextFieldBuscaMaxSalFunc.getText();

                if (manager.isValidField(Manager.SALARY_FIELD, minSalary) || manager.isValidField(Manager.SALARY_FIELD, maxSalary)) {
                    try {
                        employees = core.searchEmployeeBySalary(employees, Double.valueOf(minSalary), Double.valueOf(maxSalary));
                        Vector<String> employeNames = new Vector<String>();
                        if (!employees.isEmpty()) {
                            for (Employee e : employees) {
                                employeNames.add(e.toString());
                            }
                        } else {
                            employeNames.add("[Nenhum resultado encontrado]");
                        }
                        jList1.setListData(employeNames);
                    } catch (Exception e) {
                        JOptionPane.showMessageDialog(this, "Erro ao realizar busca!");
                    }
                } else {
                    JOptionPane.showMessageDialog(this, "Salário inválido!");
                }
            }
            if (manager.isNotEmpty(jTextFieldBuscaMinDeptsFunc.getText(), jTextFieldBuscaMaxDeptsFunc.getText())) {
                //busca funcionário pelo número de dependentes
                minDept = jTextFieldBuscaMinDeptsFunc.getText();
                maxDept = jTextFieldBuscaMaxDeptsFunc.getText();

                if (manager.isValidField(Manager.NUM_RELATIVES_FIELD, minDept) || manager.isValidField(Manager.NUM_RELATIVES_FIELD, maxDept)) {
                    try {
                        employees = core.searchEmployeeByRelatives(employees, Integer.valueOf(minDept), Integer.valueOf(maxDept));
                        Vector<String> employeNames = new Vector<String>();
                        if (!employees.isEmpty()) {
                            for (Employee e : employees) {
                                employeNames.add(e.toString());
                            }
                        } else {
                            employeNames.add("[Nenhum resultado encontrado]");
                        }
                        jList1.setListData(employeNames);
                    } catch (Exception e) {
                        JOptionPane.showMessageDialog(this, "Erro ao realizar busca!");
                    }
                } else {
                    JOptionPane.showMessageDialog(this, "Número de dependentes inválido!");
                }
            }
            employees = null;

        } else if (jRadioButtonBuscaDept.isSelected()) {
            List<Relative> relatives = null;
            String name = null;
            String minAge = null;
            String maxAge = null;
            if (manager.isNotEmpty(jTextFieldBuscaNomeDept.getText())) {
                //busca dependente por nome
                name = jTextFieldBuscaNomeDept.getText();

                if (manager.isValidField(Manager.NAME_FIELD, name)) {
                    try {
                        relatives = core.searchRelativeByName(relatives, name);
                        Vector<String> relativeNames = new Vector<String>();
                        if (!relatives.isEmpty()) {
                            for (Relative r : relatives) {
                                relativeNames.add(r.toString());
                            }
                        } else {
                            relativeNames.add("[Nenhum resultado encontrado]");
                        }
                        jList1.setListData(relativeNames);
                    } catch (Exception e) {
                        JOptionPane.showMessageDialog(this, "Erro ao realizar busca!");
                    }
                } else {
                    JOptionPane.showMessageDialog(this, "Nome inválido!");
                }
            }
            if (manager.isNotEmpty(jTextFieldBuscaMinAgeDept.getText(), jTextFieldBuscaMaxAgeDept.getText())) {
                //busca dependente por idade
                minAge = jTextFieldBuscaMinAgeDept.getText();
                maxAge = jTextFieldBuscaMaxAgeDept.getText();

                if (manager.isValidField(Manager.AGE_FIELD, minAge) || manager.isValidField(Manager.AGE_FIELD, maxAge)) {
                    try {
                        relatives = core.searchRelativeByAge(relatives, Integer.valueOf(minAge), Integer.valueOf(maxAge));
                        Vector<String> relativeNames = new Vector<String>();
                        if (!relatives.isEmpty()) {
                            for (Relative r : relatives) {
                                relativeNames.add(r.toString());
                            }
                        } else {
                            relativeNames.add("[Nenhum resultado encontrado]");
                        }
                        jList1.setListData(relativeNames);
                    } catch (Exception e) {
                        JOptionPane.showMessageDialog(this, "Erro ao realizar busca!");
                    }
                } else {
                    JOptionPane.showMessageDialog(this, "Idade inválida!");
                }
            }
            relatives = null;
        } else if (jRadioButtonListDept.isSelected()) {
            List<Employee> employees = null;
            List<Relative> relatives = null;
            Vector<String> relativeNames = null;
            String name = null;

            try {
                name = jTextFieldBuscaNomeFunc.getText();
            } catch (Exception e) {
            }

            if (name.isEmpty()) {
                try {
                    relatives = Arquivos.leRelatives(Arquivos.ARQ_TAB_DADOS_RELATIVE);

                    relativeNames = new Vector<String>();
                    if (!relatives.isEmpty()) {
                        for (Relative r : relatives) {
                            relativeNames.add(r.toString());
                        }
                    } else {
                        relativeNames.add("[Nenhum resultado encontrado]");
                    }
                    jList1.setListData(relativeNames);
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(this, "Erro ao realizar busca!");
                }
            } else {
                if (manager.isValidField(Manager.NAME_FIELD, name)) {
                    try {
                        employees = core.searchEmployeeByName(null, name);
                        relatives = core.ListRelativesByEmployee(employees.get(0));

                        relativeNames = new Vector<String>();
                        if (!relatives.isEmpty()) {
                            for (Relative r : relatives) {
                                relativeNames.add(r.toString());
                            }
                        } else {
                            relativeNames.add("[Nenhum resultado encontrado]");
                        }
                        jList1.setListData(relativeNames);
                    } catch (Exception e) {
                        JOptionPane.showMessageDialog(this, "Erro ao realizar busca!");
                    }
                } else {
                    JOptionPane.showMessageDialog(this, "Nome inválido!");
                }
            }

        } else if (jRadioButtonListFunc.isSelected()) {
            List<Employee> employees = null;
            Vector<String> employeeNames = null;

            try {
                employees = Arquivos.leEmployees(Arquivos.ARQ_TAB_DADOS_EMPLOYEE);

                employeeNames = new Vector<String>();
                if (!employees.isEmpty()) {
                    for (Employee e : employees) {
                        employeeNames.add(e.toString());
                    }
                } else {
                    employeeNames.add("[Nenhum resultado encontrado]");
                }
                jList1.setListData(employeeNames);
            } catch (Exception e) {
                JOptionPane.showMessageDialog(this, "Erro ao realizar busca!");
            }
        }

    } catch (Exception e) {
    }
}//GEN-LAST:event_jButtonBuscaBuscarActionPerformed

private void jButtonDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeleteActionPerformed
    if (manager.isNotEmpty(jTextFieldDelCode.getText())) {
        int codeToDelete = Integer.valueOf(jTextFieldDelCode.getText());
        if (jRadioButtonDelFunc.isSelected()) {
            if (core.removeEmployee(codeToDelete)) {
                JOptionPane.showMessageDialog(rootPane, "Funcionário [" + codeToDelete + "] deletado com sucesso!");
            } else {
                JOptionPane.showMessageDialog(rootPane, "Erro ao deletear funcionário!");
            }
        } else if (jRadioButtonDelDept.isSelected()) {
            if (core.removeRelative(codeToDelete)) {
                JOptionPane.showMessageDialog(rootPane, "Dependente [" + codeToDelete + "] deletado com sucesso!");
            } else {
                JOptionPane.showMessageDialog(rootPane, "Erro ao deletear dependente!");
            }
        }
    }
    core.print();
}//GEN-LAST:event_jButtonDeleteActionPerformed

private void jButtonPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPrintActionPerformed
    core.print();
}//GEN-LAST:event_jButtonPrintActionPerformed

private void jButtonResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonResetActionPerformed
    core.reset();
}//GEN-LAST:event_jButtonResetActionPerformed

private void jButtonEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEditActionPerformed
    if (manager.isNotEmpty(jTextFieldEditCode.getText())) {
        if (jRadioButtonEditFunc.isSelected()) {
            jFrameEditFunc.setVisible(true);
            jPanelEditFunc.setVisible(true);
        } else if (jRadioButtonEditDept.isSelected()) {
            jFrameEditDept.setVisible(true);
            jPanelEditDept.setVisible(true);
        }
    } else {
        JOptionPane.showMessageDialog(rootPane, "É necessário um ID para edição!");
    }
    core.print();
}//GEN-LAST:event_jButtonEditActionPerformed

private void jButtonEditCancelFuncActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEditCancelFuncActionPerformed
    jTextFieldEditNomeFunc.setText("");
    jTextFieldEditAgeFunc.setText("");
    jTextFieldEditSalFunc.setText("");
    jFrameEditFunc.setVisible(false);
}//GEN-LAST:event_jButtonEditCancelFuncActionPerformed

private void jButtonEditFuncActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEditFuncActionPerformed

    int codeToEdit = Integer.valueOf(jTextFieldEditCode.getText());
    String newName = null;
    String newAge = null;
    String newSalary = null;

    boolean changeName = false;
    boolean changeAge = false;
    boolean changeSalary = false;

    try {
        newName = jTextFieldEditNomeFunc.getText();
        if (manager.isValidField(Manager.NAME_FIELD, newName)) {
            changeName = true;
        }
    } catch (Exception e) {
        changeName = false;
    }
    try {
        newAge = jTextFieldEditAgeFunc.getText();
        if (manager.isValidField(Manager.AGE_FIELD, newAge)) {
            changeAge = true;
        }
    } catch (Exception e) {
        changeAge = false;
    }
    try {
        newSalary = jTextFieldEditSalFunc.getText();
        if (manager.isValidField(Manager.SALARY_FIELD, newSalary)) {
            changeSalary = true;
        }
    } catch (Exception e) {
        changeSalary = false;
    }

    if (manager.isValidField(Manager.NAME_FIELD, newName)
            || manager.isValidField(Manager.AGE_FIELD, newAge)
            || manager.isValidField(Manager.SALARY_FIELD, newSalary)) {

        if (core.editEmployee(codeToEdit, (changeName ? newName : ""),
                Integer.valueOf((changeAge ? newAge : "-1")),
                Double.valueOf((changeSalary ? newSalary : "-1")))) {
            JOptionPane.showMessageDialog(rootPane, "Funcionário [" + codeToEdit + "] editado com sucesso!");
        } else {
            JOptionPane.showMessageDialog(rootPane, "Erro ao editar funcionário!");
        }
    } else {
        JOptionPane.showMessageDialog(rootPane, "Campos inválidos!");
    }

    jPanelEditFunc.setVisible(false);
    jFrameEditFunc.setVisible(false);

    core.print();
}//GEN-LAST:event_jButtonEditFuncActionPerformed

private void jButtonEditDeptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEditDeptActionPerformed
    int codeToEdit = Integer.valueOf(jTextFieldEditCode.getText());
    String newName = null;
    String newAge = null;
    String newEmployeeID = null;

    boolean changeName = false;
    boolean changeAge = false;
    boolean changeEmployeeId = false;

    try {
        newName = jTextFieldEditNomeDept.getText();
        if (manager.isValidField(Manager.NAME_FIELD, newName)) {
            changeName = true;
        }
    } catch (Exception e) {
        changeName = false;
    }
    try {
        newAge = jTextFieldEditAgeDept.getText();
        if (manager.isValidField(Manager.AGE_FIELD, newAge)) {
            changeAge = true;
        }
    } catch (Exception e) {
        changeAge = false;
    }
    try {
        newEmployeeID = jTextFieldEditFuncDept.getText();
        if (manager.isValidField(Manager.PERSON_ID_FIELD, newEmployeeID)) {
            changeEmployeeId = true;
        }
    } catch (Exception e) {
        changeEmployeeId = false;
    }

    if (manager.isValidField(Manager.NAME_FIELD, newName)
            || manager.isValidField(Manager.AGE_FIELD, newAge)
            || manager.isValidField(Manager.PERSON_ID_FIELD, newEmployeeID)) {

        if (core.editRelative(codeToEdit, (changeName ? newName : ""),
                Integer.valueOf((changeAge ? newAge : "-1")),
                Integer.valueOf((changeEmployeeId ? newEmployeeID : "-1")))) {
            JOptionPane.showMessageDialog(rootPane, "Dependente [" + codeToEdit + "] editado com sucesso!");
        } else {
            JOptionPane.showMessageDialog(rootPane, "Erro ao editar dependente!");
        }
    } else {
        JOptionPane.showMessageDialog(rootPane, "Campos inválidos!");
    }

    jPanelEditDept.setVisible(false);
    jFrameEditDept.setVisible(false);

    core.print();
}//GEN-LAST:event_jButtonEditDeptActionPerformed

private void jButtonEditCancelDeptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEditCancelDeptActionPerformed
    jTextFieldEditNomeDept.setText("");
    jTextFieldEditAgeDept.setText("");
    jTextFieldEditFuncDept.setText("");
    jFrameEditDept.setVisible(false);
}//GEN-LAST:event_jButtonEditCancelDeptActionPerformed

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                try {
                    new mainUI().setVisible(true);


                } catch (IOException ex) {
                    Logger.getLogger(mainUI.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroupBusca;
    private javax.swing.ButtonGroup buttonGroupDelete;
    private javax.swing.ButtonGroup buttonGroupEdit;
    private javax.swing.JButton jButtonBuscaBuscar;
    private javax.swing.JButton jButtonBuscaCancelar;
    private javax.swing.JButton jButtonCadastraDept;
    private javax.swing.JButton jButtonCadastraFunc;
    private javax.swing.JButton jButtonCancelaDept;
    private javax.swing.JButton jButtonCancelaFunc;
    private javax.swing.JButton jButtonDelete;
    private javax.swing.JButton jButtonEdit;
    private javax.swing.JButton jButtonEditCancelDept;
    private javax.swing.JButton jButtonEditCancelFunc;
    private javax.swing.JButton jButtonEditDept;
    private javax.swing.JButton jButtonEditFunc;
    private javax.swing.JButton jButtonPrint;
    private javax.swing.JButton jButtonReset;
    private javax.swing.JFrame jFrameEditDept;
    private javax.swing.JFrame jFrameEditFunc;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JList jList1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JPanel jPanelBusca;
    private javax.swing.JPanel jPanelCadDep;
    private javax.swing.JPanel jPanelCadFunc;
    private javax.swing.JPanel jPanelCadastra;
    private javax.swing.JPanel jPanelEditDept;
    private javax.swing.JPanel jPanelEditFunc;
    private javax.swing.JRadioButton jRadioButtonBuscaDept;
    private javax.swing.JRadioButton jRadioButtonBuscaFunc;
    private javax.swing.JRadioButton jRadioButtonDelDept;
    private javax.swing.JRadioButton jRadioButtonDelFunc;
    private javax.swing.JRadioButton jRadioButtonEditDept;
    private javax.swing.JRadioButton jRadioButtonEditFunc;
    private javax.swing.JRadioButton jRadioButtonListDept;
    private javax.swing.JRadioButton jRadioButtonListFunc;
    private javax.swing.JScrollPane jScrollPaneResultadoBusca;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField jTextFieldBuscaMaxAgeDept;
    private javax.swing.JTextField jTextFieldBuscaMaxAgeFunc;
    private javax.swing.JTextField jTextFieldBuscaMaxDeptsFunc;
    private javax.swing.JTextField jTextFieldBuscaMaxSalFunc;
    private javax.swing.JTextField jTextFieldBuscaMinAgeDept;
    private javax.swing.JTextField jTextFieldBuscaMinAgeFunc;
    private javax.swing.JTextField jTextFieldBuscaMinDeptsFunc;
    private javax.swing.JTextField jTextFieldBuscaMinSalFunc;
    private javax.swing.JTextField jTextFieldBuscaNomeDept;
    private javax.swing.JTextField jTextFieldBuscaNomeFunc;
    private javax.swing.JTextField jTextFieldCadAgeDept;
    private javax.swing.JTextField jTextFieldCadAgeFunc;
    private javax.swing.JTextField jTextFieldCadDeptFunc;
    private javax.swing.JTextField jTextFieldCadNomeDept;
    private javax.swing.JTextField jTextFieldCadNomeFunc;
    private javax.swing.JTextField jTextFieldCadSalFunc;
    private javax.swing.JTextField jTextFieldDelCode;
    private javax.swing.JTextField jTextFieldEditAgeDept;
    private javax.swing.JTextField jTextFieldEditAgeFunc;
    private javax.swing.JTextField jTextFieldEditCode;
    private javax.swing.JTextField jTextFieldEditFuncDept;
    private javax.swing.JTextField jTextFieldEditNomeDept;
    private javax.swing.JTextField jTextFieldEditNomeFunc;
    private javax.swing.JTextField jTextFieldEditSalFunc;
    // End of variables declaration//GEN-END:variables
}
